﻿Imports System.Data.SqlClient
Public Class FrmDoiMatKhau
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim tbl As DataTable
        Dim dbAdapter As SqlDataAdapter
        Dim dbComm As SqlCommand
        dbComm = New SqlCommand("select * from dbo.login where TenDangNhap= '" & TextTenDangNhap.Text & "'  and MatKhau= '" & TextMatKhauCu.Text & "' ", ob_cnn)
        dbAdapter = New SqlDataAdapter(dbComm)
        tbl = New DataTable()
        dbAdapter.Fill(tbl)
        ob_cnn.Close()
        If tbl.Rows.Count > 0 And TextMatKhauMoi.Text = TextXacNhanMatKhau.Text Then
            Dim Sql As String = ""
            Sql = " Update LOGIN Set  Matkhau = '" & TextMatKhauMoi.Text & "'  where TenDangNhap= '" & TextTenDangNhap.Text & "'  "
            Dim cmd As New SqlCommand(Sql, ob_cnn)
            ob_cnn.Open()
            cmd.ExecuteNonQuery()
            m_DangNhapThanhCong = True
            m_tennhap = TextTenDangNhap.Text
            MessageBox.Show("Đổi mật khẩu thành công")
            ob_cnn.Close()
            '  Me.Close()
        Else
            MessageBox.Show("Kiem tra lại mật khẩu mới vừa nhập ")
        End If
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

End Class